feat: declarative config_overrides for FixtureLoader - #10
Merged
Conversation
Consumers that suppress a write-time side effect keyed on a config static (auto-scaffolding, auto-publishing, denormalisation hooks) previously needed a bespoke onBeforeLoad Extension. Expose a config_overrides map so those statics can be forced per class in YAML instead. Each override is applied from a FixtureBlueprint beforeCreate callback, which runs inside FixtureBlueprint's own Config::nest()/unnest() window, so the value is live only for that record's write and reverts immediately afterwards. It is applied before the onBeforeLoad hook so a consumer's dynamic extension can still override the same class. The onBeforeLoad hook stays for anything a static value cannot express (dynamic values, non-config side effects).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a declarative
config_overridesmap toFixtureLoaderso consuming modules can force config statics on specific classes during a fixture write — without hand-rolling a bespokeonBeforeLoadextension.This targets the common case where a model has a write-time side effect keyed on a config static (auto-scaffolding, auto-publishing, denormalisation hooks) that must be suppressed while top-down fixtures are loaded. Previously each consumer wrote an
Extensionsubclass; now it's YAML:How it works
Each override is applied from a
FixtureBlueprintbeforeCreatecallback.FixtureBlueprint::createObject()invokes that callback inside its ownConfig::nest()/unnest()window, so the value is live only for that record's write and reverts immediately afterwards — it never leaks into normal app code. Overrides are applied before theonBeforeLoadhook, so a consumer's dynamic extension can still override the same class (a laterFixtureFactory::define()wins).The
onBeforeLoadhook remains for anything a static value can't express (dynamic values, non-config side effects).Design rationale
This is configuration (which statics, what values), not behaviour — so expressing it as YAML rather than a PHP
Extensionis the more honest abstraction. It does not remove any flexibility: the hook is still there for the dynamic cases.Tests
Four integration tests on
FixtureLoaderTest, covering the full contract:config_overridesis a no-op (default[])Backed by two support models:
E2eScaffoldingObject(proves real suppression behaviour) andE2eConfigProbeObject(observes the override at write time and proves no leak).Verification
Consumer migration (separate repo)
A consuming module can now delete its bespoke suppression
Extension+ itsextensions:registration and replace both with theconfig_overridesblock above. Not included here — that's a change in the consuming repo.